﻿using Grow.Scheduler.Job;

namespace Grow.Scheduler
{
    /// <summary>
    /// 任务调度
    /// </summary>
    public interface IScheduler
    {
        /// <summary>
        /// 删除任务
        /// </summary>
        /// <param name="jobId"></param>
        void RemoveJob(string jobId);

        /// <summary>
        /// 触发任务
        /// </summary>
        /// <param name="jobId"></param>
        void TriggerJob(string jobId);
        /// <summary>
        /// 添加定时任务
        /// </summary>
        /// <typeparam name="TJob"></typeparam>
        /// <param name="jobId"></param>
        /// <param name="cron"></param>
        /// <param name="cancellationToken"></param>
        void AddJob<TJob>(string jobId, string cron, CancellationToken cancellationToken = default) where TJob : class, IJob;

        /// <summary>
        /// 添加定时任务
        /// </summary>
        /// <typeparam name="TJob"></typeparam>
        /// <param name="jobId"></param>
        /// <param name="cron"></param>
        /// <param name="cancellationToken"></param>
        void AddJob<TJob, TJobData>(string jobId, TJobData jobData, string cron, CancellationToken cancellationToken = default) where TJob : class, IJob<TJobData>;

        /// <summary>
        /// 添加延时任务
        /// </summary>
        /// <typeparam name="TJob"></typeparam>
        /// <param name="jobId"></param>
        /// <param name="cron"></param>
        /// <param name="cancellationToken"></param>
        void AddSchedule<TJob>(DateTimeOffset enqueueAt, CancellationToken cancellationToken = default) where TJob : class, IJob;

        /// <summary>
        /// 添加延时任务
        /// </summary>
        /// <typeparam name="TJob"></typeparam>
        /// <typeparam name="TJobData"></typeparam>
        /// <param name="jobData"></param>
        /// <param name="enqueueAt"></param>
        /// <param name="cancellationToken"></param>
        void AddSchedule<TJob, TJobData>(TJobData jobData, DateTimeOffset enqueueAt, CancellationToken cancellationToken = default) where TJob : class, IJob<TJobData>;
    }
}
